package base;

import java.util.List;

// 子类：Teacher 继承自 Person，扩展职称与授课功能
public class Teacher extends Person {
    private String title;         // 职称
    private List<Course> courses; // 所授课程

    // 子类构造方法，调用父类构造方法
    public Teacher(String id, String name, String gender, String title, List<Course> courses) {
        super(id, name, gender);  // 调用父类构造方法
        this.title = title;
        this.courses = courses;
    }

    // 添加课程
    public void addCourse(Course course) {
        courses.add(course);
    }

    // 展示所开设的课程
    public void openCourses() {
        System.out.println(title + " " + name + " 开设的课程：");
        if (courses.isEmpty()) {
            System.out.println("暂无课程。");
        } else {
            for (Course course : courses) {
                System.out.println("- " + course.getCourseName() + "（地点：" + course.getLocation() + "，时间：" + course.getTime() + "）");
            }
        }
    }
}

